#include <stdio.h>
#include <stdlib.h>
#include <time.h>
typedef int ElemType;
#define N 7
void print(ElemType A[])
{
    int i;
    for(i=0;i<N;i++)
    {
        printf("%3d",A[i]);
    }
    printf("\n");
}
void Merge(ElemType A[],int low,int mid,int high)
{
    static ElemType B[N];
    int i,j,k;
    for(k=low;k<=high;k++)
    {
        B[k]=A[k];
    }
    for(i=low,j=mid+1,k=i;i<=mid&&j<=high;k++)
    {
        if(B[i]<B[j])
        {
            A[k]=B[i];
            i++;
        }
        else
        {
            A[k]=B[j];
            j++;
        }
    }
    while(i<=mid)
    {
        A[k]=B[i];
        i++;
        k++;
    }
    while(j<=high)
    {
        A[k]=B[j];
        j++;
        k++;
    }
}
void Mergesort(ElemType A[],int low,int high)
{
    if(low<high)
    {
        int mid=(low+high)/2;
        Mergesort(A,low,mid);
        Mergesort(A,mid+1,high);
        Merge(A,low,mid,high);
    }
}
int main()
{
    ElemType A[7]={49,38,65,97,76,13,27};
    Mergesort(A,0,6);
    print(A);
    return 0;
}